Skip to content

ci: Enable ruff rules to enforce snake_case method naming.#140

Merged
nedseb merged 1 commit intomainfrom
fix/ruff-snake-case-rule
Mar 15, 2026
Merged

ci: Enable ruff rules to enforce snake_case method naming.#140
nedseb merged 1 commit intomainfrom
fix/ruff-snake-case-rule

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 15, 2026

Closes #135

Summary

Enable 4 ruff naming rules to prevent camelCase regressions and enforce project conventions:

Rule Description
N802 Function name should be lowercase
N803 Argument name should be lowercase
N806 Variable in function should be lowercase
T20 No print() in production code (examples excluded)

Fixes to pass the new rules

File Fix
pyproject.toml Add N802, N803, N806, T20 to select; exclude examples from T20+N806
lib/lis2mdl/device.py uTmag_ut, Ttemp, NORMALIZATION_THRESHOLDnorm_threshold, Xh/Yhxh/yh; # noqa: N802 on read_magnet_uT()/magnitude_uT()
lib/wsen-hids/device.py t0_degCt0_degc, t1_degCt1_degc (local variables only, dict keys unchanged)
lib/hts221/device.py lowerBytelo, higherBytehi
lib/bq27441/device.py # noqa: N803 on capacity_mAh parameter
lib/ssd1327/examples/rotating_3d_cube.py drawCube()draw_cube()

Test plan

ruff check lib/                          # All checks passed
python3 -m pytest tests/ -k "mock" -v    # 99 passed

@nedseb nedseb requested a review from Copilot March 15, 2026 07:22
@nedseb nedseb self-assigned this Mar 15, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables a Ruff naming rule to prevent reintroducing CamelCase/mixed-case function and method names across the repository now that the driver API migration is complete.

Changes:

  • Enable Ruff N802 in pyproject.toml.
  • Add targeted # noqa: N802 suppressions for LIS2MDL methods where uT uses an uppercase unit symbol.
  • Rename an SSD1327 example helper from drawCube() to draw_cube().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Turns on Ruff N802 to flag mixed-case function/method names.
lib/lis2mdl/lis2mdl/device.py Suppresses N802 for µT-related APIs that intentionally include an uppercase T.
lib/ssd1327/examples/rotating_3d_cube.py Renames an example function to avoid mixed-case naming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
@nedseb nedseb force-pushed the fix/ruff-snake-case-rule branch from 8f773a6 to a924f26 Compare March 15, 2026 07:28
@nedseb nedseb requested a review from Copilot March 15, 2026 07:28
@nedseb nedseb force-pushed the fix/ruff-snake-case-rule branch from a924f26 to 5f99e8a Compare March 15, 2026 07:31
@nedseb nedseb changed the title ci: Enable ruff N802 rule to enforce snake_case method naming. ci: Enable ruff rules to enforce snake_case method naming. Mar 15, 2026
@nedseb nedseb merged commit c775c29 into main Mar 15, 2026
4 checks passed
@nedseb nedseb deleted the fix/ruff-snake-case-rule branch March 15, 2026 07:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens the repository’s Python linting by enabling Ruff naming rules to prevent camelCase-style regressions and enforce lowercase naming conventions, along with disallowing print() in non-example production code.

Changes:

  • Enable Ruff rules N802/N803/N806 and T20, with per-file ignores for examples and tests where appropriate.
  • Rename local variables in a few drivers to comply with the new naming rules (keeping public API/dict keys stable where needed).
  • Update one example script to use a snake_case function name.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Enables new Ruff rules and adds per-file ignores for examples/tests.
lib/lis2mdl/lis2mdl/device.py Renames locals to satisfy naming rules; adds targeted noqa where API names intentionally contain uT.
lib/wsen-hids/wsen_hids/device.py Renames local calibration variables to lowercase (dict keys unchanged).
lib/hts221/hts221/device.py Renames local variables in _read_reg16 to lowercase.
lib/bq27441/bq27441/device.py Adds targeted noqa for a parameter name kept for API compatibility.
lib/ssd1327/examples/rotating_3d_cube.py Renames drawCube() to draw_cube() to comply with naming rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: Add ruff rule to enforce snake_case method naming.

2 participants